package com.briup.jz.web.controller;

import com.briup.jz.bean.extend.AccountEmployeeExtend;
import com.briup.jz.service.ICheckService;
import com.briup.jz.service.ICommentService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 马志宇
 * @project: jz
 * @description:
 * @create: 2020/6/13 17:59
 */
@RestController
@RequestMapping("/check")
@Api(description = "审核管理接口")
public class CheckController {
    @Autowired
    private ICheckService checkService;
    @Autowired
    private ICommentService commentService;

    /**
     * 1. 员工身份审核
     */
    @ApiOperation(value = "通过状态查找所有员工")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "不填、“未审核”、“用户正常”或“用户禁止”", required = false, paramType = "query")
    })
    @GetMapping("queryEmployees_check")
    public Message queryEmployees_check(String status){
        return MessageUtil.success("查询成功", checkService.queryEmployees_check(status));
    }

    @ApiOperation(value = "审核通过")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query")
    })
    @GetMapping("pass_employee")
    public Message pass_employee(long id){
        checkService.pass_employee(id);
        return MessageUtil.success("审核成功");
    }

    @ApiOperation(value = "审核不通过")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query")
    })
    @GetMapping("fail_employee")
    public Message fail_employee(long id){
        checkService.fail_employee(id);
        return MessageUtil.success("审核成功");
    }

    @ApiOperation(value = "查找员工信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query")
    })
    @GetMapping("findById")
    public Message findById(long id){
        return MessageUtil.success("审核完毕，data为用户状态", checkService.findById(id).getStatus());
    }


    @ApiOperation(value = "更新员工的状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query"),
            @ApiImplicitParam(name = "status", value = "“用户正常”或“用户禁用”", required = true, paramType = "query")
    })
    @PostMapping("updateEmployeeStatus")
    public Message updateStatus_check(long id, String status){
        checkService.updateStatus_check(id, status);
        return MessageUtil.success("更新状态成功");
    }


    /**
     * 2. 提现审核
     */
    @ApiOperation(value = "查找所有员工的交易")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "不填、“提现”或“充值”", required = false, paramType = "query")
    })
    @GetMapping("findAllWithdrawal")
    public Message findAllWithdrawal(String status){
        return MessageUtil.success("查找成功", checkService.findAllWithdrawal(status));
    }

    @ApiOperation(value = "检查此次提现")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query"),
            @ApiImplicitParam(name = "amount", value = "本次提现的金额", required = true, paramType = "query")
    })
    @GetMapping("checkWithdrawal")
    public Message checkWithdrawal(long id, long amount){
        return MessageUtil.success("审核完毕，data为提现完毕后的余额（-1则不能提现）", checkService.checkWithdrawal(id, amount));
    }

    @ApiOperation(value = "审核提现，更新交易的状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "员工的id，唯一编号", required = true, paramType = "query"),
            @ApiImplicitParam(name = "amount", value = "本次提现的金额", required = true, paramType = "query")
    })
    @PostMapping("updateStatus")
    public Message updateStatus(long id, long amount){
        checkService.updateStatus(id, amount);
        return MessageUtil.success("审核完毕");
    }


    /**
     * 3. 仲裁
     */
    @ApiOperation(value = "通过状态查找所有投诉")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "不填、“待仲裁”或“仲裁完毕”", required = false, paramType = "query")
    })
    @GetMapping("queryComplaints")
    public Message queryComplaints(String status){
        return MessageUtil.success("查找成功", checkService.queryComplaints(status));
    }


    @ApiOperation(value = "仲裁")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "投诉的id，唯一标识", required = true, paramType = "query")
    })
    @GetMapping("arbitrate")
    public Message deleteById(long id){
        commentService.deleteById(id);
        return MessageUtil.success("仲裁完毕，投诉已删除");
    }

}
